const express = require('express')
const router = express.Router()
const passport = require('passport')
const User = require('../models/user.model')

router.get('/login',
  passport.authenticate('google', { scope:
      [ 'email', 'profile' ] }
));

router.get('/logout',(req,res) =>{
    req.logout()

    res.redirect('/')
});

router.get( '/login/callback',
    passport.authenticate( 'google', {
      scope: ['profile'],
        successRedirect: '/',
        failureRedirect: '/login/failure'
    }));

router.get('/google/redirect', passport.authenticate('google'), (req, res) =>{
    res.redirect('/profile')
});

module.exports = router
